package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.cxhc.system.domain.app.RpBuildingRubbishSort;
import com.cxhc.system.service.app.IRpBuildingRubbishSortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 楼宇垃圾分类Controller
 * 
 * @author Dhq
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/api/buildingRubbishSort")
public class ApiRpBuildingRubbishSort extends BaseController
{
    @Autowired
    private IRpBuildingRubbishSortService rpBuildingRubbishSortService;

    /**
     * 查询楼宇垃圾分类列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RpBuildingRubbishSort rpBuildingRubbishSort)
    {
        startPage();
        List<RpBuildingRubbishSort> list = rpBuildingRubbishSortService.selectRpBuildingRubbishSortList(rpBuildingRubbishSort);
        return getDataTable(list);
    }

    /**
     * 导出楼宇垃圾分类列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RpBuildingRubbishSort rpBuildingRubbishSort)
    {
        List<RpBuildingRubbishSort> list = rpBuildingRubbishSortService.selectRpBuildingRubbishSortList(rpBuildingRubbishSort);
        ExcelUtil<RpBuildingRubbishSort> util = new ExcelUtil<RpBuildingRubbishSort>(RpBuildingRubbishSort.class);
        util.exportExcel(response, list, "楼宇垃圾分类数据");
    }

    /**
     * 获取楼宇垃圾分类详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rpBuildingRubbishSortService.selectRpBuildingRubbishSortById(id));
    }

    /**
     * 新增楼宇垃圾分类
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody RpBuildingRubbishSort rpBuildingRubbishSort)
    {
        return toAjax(rpBuildingRubbishSortService.insertRpBuildingRubbishSort(rpBuildingRubbishSort));
    }

    /**
     * 修改楼宇垃圾分类
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody RpBuildingRubbishSort rpBuildingRubbishSort)
    {
        return toAjax(rpBuildingRubbishSortService.updateRpBuildingRubbishSort(rpBuildingRubbishSort));
    }

    /**
     * 删除楼宇垃圾分类
     */
	@DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rpBuildingRubbishSortService.deleteRpBuildingRubbishSortById(id));
    }
}
